package com.artisan.provider.service.impl;

import com.artisan.provider.domain.ZgCommentMessage;
import com.artisan.provider.mapper.ZgCommentMessageMapper;
import com.artisan.provider.service.ZgCommentMessageService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZgCommentMessageServiceImpl implements ZgCommentMessageService {


    @Autowired
    ZgCommentMessageMapper zgCommentMessageMapper;

    @Override
    public List<ZgCommentMessage> findAll(int page, int limit, ZgCommentMessage zgCommentMessage) {
        if(page > 0 && limit > 0){
            PageHelper.startPage(page,limit);
        }
        return zgCommentMessageMapper.findAll(zgCommentMessage);
    }

    @Override
    public int add(ZgCommentMessage zgCommentMessage) {
        int i = 0;
        try {
            return zgCommentMessageMapper.insertSelective(zgCommentMessage);
        }catch (Exception e){
            return i;
        }
    }

    @Override
    public int update(ZgCommentMessage zgCommentMessage) {
        int i = 0;
        try {
            return zgCommentMessageMapper.updateByPrimaryKeySelective(zgCommentMessage);
        }catch (Exception e){
            return i;
        }
    }

    @Override
    public int delete(int id) {
        return zgCommentMessageMapper.deleteByPrimaryKey(id);
    }
}
